//
//  Dictionary+Extension.swift
//  SwiftProject
//
//  Created by qindong on 2021/6/9.
//

import Foundation

extension Dictionary {
    var toJSONString : String {
        if let data = try? JSONSerialization.data(withJSONObject: self, options: []) {
            return String(data: data, encoding: .utf8)!
        }
        return ""
    }
    
    mutating func merge(dict: [Key: Value]) {
        for (k, v) in dict {
            if let v = v as? Bool {
                updateValue(v == true ? 1 as! Value : 0 as! Value, forKey: k)
            } else {
                updateValue(v, forKey: k)
            }
        }
    }
}
